using System;

namespace MEA.AE_Data
{
	public abstract class ConfigDTCBase : ConfigBase
	{
		public enum EDTCSigClass
		{
			eSig_AngCrS_CSTR,
			eSig_r_CSTR,
			eSig_OneToOne_CSTR,
			eSig_q_CSTR,
			eSig_OneToOnet_CSTR,
			eSig_t_CSTR,
			eSig_n_CSTR,
			eSig_p_CSTR,
			eSig_uBatt_CSTR,
			eSig_uPrplCD_CSTR,
			eSig_curr_CSTR,
			eSig_stLow_CSTR,
			eSig_stHigh_CSTR,
			eSig_lengthmm_CSTR,
			eSig_stByte2_CSTR,
			eSig_stByte3_CSTR,
			eSig_stByte4_LSB_CSTR,
			eSig_unused_DLen,
			eSig_Env_CSTR,
			eSig_dcyc_CSTR,
			eSig_RailPres_CSTR,
			eSig_u_CSTR,
			eNot_found,
			eSig_Last_CSTR
		}

		public struct SSigClass
		{
			private int envConvert;

			private double envScale;

			private double envOffset;

			private EUnits envUnit;

			private EStringFormat envFormat;

			public void setSigClass(int env_Conv, double env_Scale, double env_Offset, EUnits env_Units, EStringFormat env_Format)
			{
				envConvert = env_Conv;
				envScale = env_Scale;
				envOffset = env_Offset;
				envUnit = env_Units;
				envFormat = env_Format;
			}

			public double GetVal(double xVal)
			{
				return xVal * envScale + envOffset;
			}

			public string GetValAsString(object val)
			{
				string text = string.Empty;
				double num = 0.0;
				byte b = (byte)val;
				switch (envConvert)
				{
				case 0:
					num = envScale * (double)(int)b + envOffset;
					text = string.Format(ConfigBase.StrStringFormat[(uint)envFormat], (int)num);
					break;
				case 1:
					num = envScale * (double)b + envOffset;
					text = string.Format(ConfigBase.StrStringFormat[(uint)envFormat], num);
					break;
				case 2:
					num = envScale * (double)(int)b + envOffset;
					text = string.Format(ConfigBase.StrStringFormat[(uint)envFormat], (int)num);
					break;
				case 3:
				{
					num = envScale * (double)(int)b + envOffset;
					text = Convert.ToString((byte)num, 2);
					int num2 = 8 - text.Length;
					for (int i = 0; i < num2; i++)
					{
						text = "0" + text;
					}
					break;
				}
				case 4:
					num = envScale * (double)(int)b + envOffset;
					text = string.Format(ConfigBase.StrStringFormat[(uint)envFormat], (int)num);
					break;
				}
				return text;
			}

			public string GetUnitStr()
			{
				return ConfigBase.SUnit[(uint)envUnit];
			}
		}
	}
}
